package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.InventoryPrice;
import cn.stylefeng.guns.sys.modular.system.model.params.InventoryPriceParam;
import cn.stylefeng.guns.sys.modular.system.service.InventoryPriceService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 控制器
 *
 * @author jiangge
 * @Date 2020-09-15 11:05:17
 */
@Controller
@RequestMapping("/inventoryPrice")
public class InventoryPriceController extends BaseController {

    private String PREFIX = "/modular/system/inventoryPrice";

    @Autowired
    private InventoryPriceService inventoryPriceService;

    /**
     * 跳转到主页面
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/inventoryPrice.html";
    }

    /**
     * 新增页面
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/inventoryPrice_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/inventoryPrice_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(InventoryPriceParam inventoryPriceParam) {
        ResponseData data=this.inventoryPriceService.addOne(inventoryPriceParam);
        return data;
    }

    /**
     * 编辑接口
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(InventoryPriceParam inventoryPriceParam) {
        ResponseData data = this.inventoryPriceService.update(inventoryPriceParam);
        return data;
    }

    /**
     * 删除接口
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(InventoryPriceParam inventoryPriceParam) {
        this.inventoryPriceService.delete(inventoryPriceParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(InventoryPriceParam inventoryPriceParam) {
        InventoryPrice detail = this.inventoryPriceService.selectOneById(inventoryPriceParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jiangge
     * @Date 2020-09-15
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(InventoryPriceParam inventoryPriceParam) {
        return this.inventoryPriceService.findPageBySpec(inventoryPriceParam);
    }

}


